<include file="Public:header" />
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script></head>

<script language="javascript">

    function getaddr() {
        WeixinJSBridge.invoke('editAddress', {
            "appId": "{$appid}", //公众号名称，由商户传入
            "timeStamp": "{$timestamp}", //时间戳 这里随意使用了一个值
            "nonceStr": "{$nonceStr}", //随机串
            "signType": "SHA1", //微信签名方式:sha1
            "addrSign": "{$addrSign}", //微信签名
            "scope": "jsapi_address"
        }, function(res) {
            WeixinJSBridge.log(res.err_msg);
            if (res.err_msg == 'edit_address:ok') {
                document.getElementById("showAddress").innerHTML =
                        "收件人：" + res.userName +
                        "  联系电话：" + res.telNumber +
                        "  收货地址：" + res.proviceFirstStageName
                        + res.addressCitySecondStageName
                        + res.addressCountiesThirdStageName
                        + res.addressDetailInfo +
                        "  邮编：" + res.addressPostalCode;
                $("#name").val(res.userName);
                $("#phone").val(res.telNumber);
                $("#province").val(res.proviceFirstStageName);
                $("#city").val(res.addressCitySecondStageName);
                $("#area").val(res.addressCountiesThirdStageName);
                $("#address").val(res.addressDetailInfo);
                $("#postcode").val(res.addressPostalCode);

            } else {
                alert("获取地址失败，请重新点击");
            }
        });
    }
</script>
<style>
    section.content{padding:10px 12px;}
    section .showaddr{border:1px dashed #C9C9C9;padding:10px 10px 15px;margin-bottom:20px;color:#666666;font-size:12px;text-align:center;}
    section .showaddr strong{font-weight:normal;color:#9900FF;font-size:26px;font-family:Helvetica;}
</style>
<section class="content">
    <div class="showaddr" id="showAddress" >
        <a id="editAddress" href="javascript:getaddr();"><strong>点击设置收货地址</strong></a>
    </div>
</section>
<div style="padding:0px; min-height:300px" id="main">
    <div class="ctop"></div>
    <form action="{:U('WeChat/Order/make')}" method="POST">
        <input type="input" id="total" name="total" value="{$countPrice}"/>
        <input type="input" id="name" name="name"/>
        <input type="input" id="phone" name="phone"/>
        <input type="input" id="province" name="province"/>
        <input type="input" id="city" name="city"/>
        <input type="input" id="area" name="area"/>
        <input type="input" id="address" name="address"/>
        <input type="input" id="postcode" name="postcode"/>
        <empty name="carts">
            <p style="font-size:20px; text-align:center; height:40px; line-height:40px; color:#b8b8b8">购物车还是空空的</p>
            <p style="font-size:20px; text-align:center; height:24px; line-height:24px; color:#b8b8b8">现在就去选购吧</p>
            <p style=" padding-top:20px;text-align:center">
                <a style="width:80px; height:30px; line-height:30px;
                   border-radius:5px; border:1px solid #b8b8b8; display:block;
                   margin:0px auto; font-size:18px; text-decoration:underline">去购物</a>
            </p>
            <else /> 
            <table style="width: 100%">
                <volist name="carts" id="vo" >
                    <tr style="line-height: 50px">
                        <td style="font-size: 14px"> {$vo.name}</td>
                        <td>
                            数量：X {$vo.num} 
                            <input type="hidden" name="pid[]" value="{$vo.id}"/>
                            <input type="hidden" name="pnum[]" value="{$vo.num}"/>
                        </td>
                        <td>单价：￥{$vo.price}</td>
                    </tr>
                </volist>

                <td> </td>
                <td> 总价：</td>
                <td> <span style="color: red;font-size: 18px">￥ {$countPrice}</span></td>
            </table>
            <p style=" padding-top:20px;text-align:center">

                <textarea name="remark">{:U('WeChat/Order/make')}</textarea>
                <button  type="submit"
                         style="width:100px; height:30px; line-height:30px;    
                         background: #DB383E; color: #FFFFFF;
                         border-radius:5px; border:1px solid #b8b8b8; display:block;
                         margin:0px auto; font-size:14px;">立刻下单</button>

            </p>

        </empty> 
    </form>

</div>

<include file="Public:footer" />